package cn.njxzc.examples;

import java.util.Date;

public class Exam7_2 implements Runnable {
	int sleepTime;
	String name;
	int counter;

	public Exam7_2(int x, String n) {
		sleepTime = x;
		name = n;
		counter = 0;
	}

	public void run() {
		while (counter < 10) {
			try {
				counter++;
				System.out.println(name + ":"
						+ new Date(System.currentTimeMillis()));
				Thread.sleep(sleepTime);
			} catch (InterruptedException e) {
				System.out.println(e);
			}
		}
	}

	public static void main(String[] args) {
		Thread t1 = new Thread(new Exam7_2(1000, "Fast Thread"));
		t1.start();
		Thread t2 = new Thread(new Exam7_2(3000, "Slow Thread"));
		t2.start();
	}
}